<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>风控管理系统 - 首页</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
            min-height: 100vh;
        }
        
        .header {
            background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
            color: white;
            padding: 1rem 2rem;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        
        .nav {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        
        .logo {
            font-size: 1.5rem;
            font-weight: bold;
        }
        
        .user-info {
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        
        .welcome-text {
            font-size: 0.9rem;
        }
        
        .logout-btn {
            background: rgba(255,255,255,0.2);
            border: 1px solid rgba(255,255,255,0.3);
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 5px;
            text-decoration: none;
            transition: all 0.3s ease;
        }
        
        .logout-btn:hover {
            background: rgba(255,255,255,0.3);
            text-decoration: none;
            color: white;
        }
        
        .main-content {
            padding: 2rem;
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .welcome-banner {
            background: white;
            border-radius: 15px;
            padding: 2rem;
            margin-bottom: 2rem;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            text-align: center;
            border-left: 5px solid #dc2626;
        }
        
        .welcome-banner h1 {
            color: #dc2626;
            margin-bottom: 1rem;
            font-size: 2.5rem;
        }
        
        .welcome-banner p {
            color: #666;
            font-size: 1.1rem;
        }
        
        .alert-banner {
            background: linear-gradient(135deg, #fef3c7 0%, #fed7aa 100%);
            border: 1px solid #f59e0b;
            border-radius: 10px;
            padding: 1rem;
            margin-bottom: 2rem;
            display: flex;
            align-items: center;
            gap: 1rem;
        }
        
        .alert-icon {
            font-size: 1.5rem;
            animation: blink 2s infinite;
        }
        
        @keyframes blink {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }
        
        .risk-stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 1rem;
            margin-bottom: 2rem;
        }
        
        .risk-card {
            background: white;
            border-radius: 10px;
            padding: 1.5rem;
            text-align: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
            border-top: 4px solid var(--border-color);
        }
        
        .risk-card.high {
            --border-color: #dc2626;
        }
        
        .risk-card.medium {
            --border-color: #f59e0b;
        }
        
        .risk-card.low {
            --border-color: #10b981;
        }
        
        .risk-card.info {
            --border-color: #3b82f6;
        }
        
        .risk-number {
            font-size: 2rem;
            font-weight: bold;
            color: var(--border-color);
        }
        
        .risk-label {
            color: #666;
            margin-top: 0.5rem;
        }
        
        .features-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 2rem;
            margin-bottom: 2rem;
        }
        
        .feature-card {
            background: white;
            border-radius: 15px;
            padding: 2rem;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.15);
        }
        
        .feature-icon {
            font-size: 3rem;
            margin-bottom: 1rem;
        }
        
        .feature-title {
            color: #dc2626;
            font-size: 1.5rem;
            margin-bottom: 1rem;
        }
        
        .feature-desc {
            color: #666;
            line-height: 1.6;
            margin-bottom: 1.5rem;
        }
        
        .feature-btn {
            background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
            color: white;
            padding: 0.75rem 1.5rem;
            border-radius: 8px;
            text-decoration: none;
            display: inline-block;
            transition: transform 0.3s ease;
        }
        
        .feature-btn:hover {
            transform: scale(1.05);
            text-decoration: none;
            color: white;
        }
        
        .system-info {
            background: white;
            border-radius: 15px;
            padding: 1.5rem;
            box-shadow: 0 4px 15px rgba(0,0,0,0.1);
            border-left: 4px solid #10b981;
        }
        
        .status-indicator {
            display: flex;
            align-items: center;
            gap: 1rem;
            margin-bottom: 1rem;
        }
        
        .status-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            animation: pulse 2s infinite;
        }
        
        .status-dot.active {
            background: #10b981;
        }
        
        .status-dot.warning {
            background: #f59e0b;
        }
        
        .status-dot.danger {
            background: #dc2626;
        }
        
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
    </style>
</head>
<body>
    <div class="header">
        <nav class="nav">
            <div class="logo">🛡️ 风控管理系统</div>
            <div class="user-info" sec:authorize="isAuthenticated()">
                <span class="welcome-text">欢迎，<span sec:authentication="name">用户</span></span>
                <a href="/logout" class="logout-btn">退出登录</a>
            </div>
        </nav>
    </div>
    
    <div class="main-content">
        <div class="welcome-banner">
            <h1>风险控制中心</h1>
            <p>实时监控，智能预警，守护企业安全</p>
            
            <!-- 已登录状态标记 -->
            <div style="background-color: #dcfce7; color: #16a34a; padding: 10px; border-radius: 5px; margin-top: 15px; font-weight: bold; border: 1px solid #16a34a; display: inline-block;">
                <span style="font-size: 16px;">✅ 当前状态：已登录</span>
            </div>
        </div>
        
        <div class="alert-banner">
            <span class="alert-icon">⚠️</span>
            <div>
                <strong>风险提醒：</strong>检测到3个高风险事件需要处理，请及时关注。
            </div>
        </div>
        
        <div class="risk-stats">
            <div class="risk-card high">
                <div class="risk-number">3</div>
                <div class="risk-label">高风险警报</div>
            </div>
            <div class="risk-card medium">
                <div class="risk-number">8</div>
                <div class="risk-label">中风险事件</div>
            </div>
            <div class="risk-card low">
                <div class="risk-number">15</div>
                <div class="risk-label">低风险监控</div>
            </div>
            <div class="risk-card info">
                <div class="risk-number">142</div>
                <div class="risk-label">今日检测</div>
            </div>
        </div>
        
        <div class="features-grid">
            <div class="feature-card">
                <div class="feature-icon">📊</div>
                <h3 class="feature-title">实时监控</h3>
                <p class="feature-desc">24/7实时监控系统状态，及时发现异常行为和潜在风险</p>
                <a href="/monitoring" class="feature-btn">进入监控</a>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">🔍</div>
                <h3 class="feature-title">风险评估</h3>
                <p class="feature-desc">智能风险评估模型，精准识别和量化各类风险因子</p>
                <a href="/assessment" class="feature-btn">开始评估</a>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">⚡</div>
                <h3 class="feature-title">预警管理</h3>
                <p class="feature-desc">自动预警系统，快速响应机制，降低风险损失</p>
                <a href="/api/alerts" class="feature-btn">查看预警</a>
            </div>
            
            <div class="feature-card">
                <div class="feature-icon">🎯</div>
                <h3 class="feature-title">风险管控</h3>
                <p class="feature-desc">全方位风险管控策略，建立完善的风险防控体系</p>
                <a href="/management" class="feature-btn">风险管控</a>
            </div>
        </div>
        
        <div class="system-info">
            <h4>🔧 系统监控状态</h4>
            <div class="status-indicator">
                <span class="status-dot active"></span>
                <span>核心监控系统：运行正常</span>
            </div>
            <div class="status-indicator">
                <span class="status-dot warning"></span>
                <span>数据采集模块：轻微延迟</span>
            </div>
            <div class="status-indicator">
                <span class="status-dot active"></span>
                <span>预警通知系统：运行正常</span>
            </div>
            <p style="margin-top: 1rem; color: #666;">
                最后更新：<span id="current-time"></span> | 
                系统版本：v2.1.0 | 
                在线用户：<span id="online-users">23</span>
            </p>
        </div>
    </div>
    
    <script>
        // 显示当前时间
        function updateTime() {
            const now = new Date();
            const timeString = now.toLocaleString('zh-CN');
            document.getElementById('current-time').textContent = timeString;
        }
        
        updateTime();
        setInterval(updateTime, 1000);
        
        // 模拟风险数据更新
        function updateRiskStats() {
            const riskNumbers = document.querySelectorAll('.risk-number');
            const values = [
                Math.floor(Math.random() * 5) + 1,  // 高风险 1-5
                Math.floor(Math.random() * 10) + 5, // 中风险 5-14
                Math.floor(Math.random() * 20) + 10, // 低风险 10-29
                Math.floor(Math.random() * 100) + 100 // 检测总数 100-199
            ];
            
            riskNumbers.forEach((element, index) => {
                element.textContent = values[index];
            });
            
            // 更新在线用户数
            const onlineUsers = Math.floor(Math.random() * 50) + 10;
            document.getElementById('online-users').textContent = onlineUsers;
        }
        
        // 每20秒更新一次风险数据
        setInterval(updateRiskStats, 20000);
        
        // 模拟风险等级变化的动画效果
        function animateRiskCards() {
            const cards = document.querySelectorAll('.risk-card');
            cards.forEach(card => {
                card.addEventListener('mouseenter', () => {
                    card.style.transform = 'scale(1.05)';
                });
                card.addEventListener('mouseleave', () => {
                    card.style.transform = 'scale(1)';
                });
            });
        }
        
        animateRiskCards();
    </script>
</body>
</html>